package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchProductionDataRecords;
import com.ruoyi.system.service.IDispatchProductionDataRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产数据记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchProductionDataRecords")
public class DispatchProductionDataRecordsController extends BaseController
{
    @Autowired
    private IDispatchProductionDataRecordsService dispatchProductionDataRecordsService;

    /**
     * 查询生产数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionDataRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchProductionDataRecords dispatchProductionDataRecords)
    {
        startPage();
        List<DispatchProductionDataRecords> list = dispatchProductionDataRecordsService.selectDispatchProductionDataRecordsList(dispatchProductionDataRecords);
        return getDataTable(list);
    }

    /**
     * 导出生产数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionDataRecords:export')")
    @Log(title = "生产数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchProductionDataRecords dispatchProductionDataRecords)
    {
        List<DispatchProductionDataRecords> list = dispatchProductionDataRecordsService.selectDispatchProductionDataRecordsList(dispatchProductionDataRecords);
        ExcelUtil<DispatchProductionDataRecords> util = new ExcelUtil<DispatchProductionDataRecords>(DispatchProductionDataRecords.class);
        util.exportExcel(response, list, "生产数据记录数据");
    }

    /**
     * 获取生产数据记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionDataRecords:query')")
    @GetMapping(value = "/{productionDataRecordsId}")
    public AjaxResult getInfo(@PathVariable("productionDataRecordsId") Long productionDataRecordsId)
    {
        return success(dispatchProductionDataRecordsService.selectDispatchProductionDataRecordsByProductionDataRecordsId(productionDataRecordsId));
    }

    /**
     * 新增生产数据记录
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionDataRecords:add')")
    @Log(title = "生产数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchProductionDataRecords dispatchProductionDataRecords)
    {
        return toAjax(dispatchProductionDataRecordsService.insertDispatchProductionDataRecords(dispatchProductionDataRecords));
    }

    /**
     * 修改生产数据记录
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionDataRecords:edit')")
    @Log(title = "生产数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchProductionDataRecords dispatchProductionDataRecords)
    {
        return toAjax(dispatchProductionDataRecordsService.updateDispatchProductionDataRecords(dispatchProductionDataRecords));
    }

    /**
     * 删除生产数据记录
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionDataRecords:remove')")
    @Log(title = "生产数据记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productionDataRecordsIds}")
    public AjaxResult remove(@PathVariable Long[] productionDataRecordsIds)
    {
        return toAjax(dispatchProductionDataRecordsService.deleteDispatchProductionDataRecordsByProductionDataRecordsIds(productionDataRecordsIds));
    }
}
